#ifndef USER_MAPPER_H
#define USER_MAPPER_H

#include <QWidget>
#include <QObject>
#include <QSqlDatabase>
#include <QString>
#include <QSqlQuery>

struct User{
    QString userId;
    QString nickName;

    User(const QString& id, const QString &nickName) : userId(id), nickName(nickName){}
};

class UserMapper
{
public:
    UserMapper()
    {
        this->db = QSqlDatabase::addDatabase("QMYSQL");
        db.setPort(3306);
    };
    ~UserMapper(){
        this->db.close();
    };

    std::vector<User> SelectUserInfoByPage(const int pageSize, const int pageNumber);


    UserMapper* setHost(const QString &host);
    UserMapper* setDatabaseName(const QString &databaseName);
    UserMapper* setUserName(const QString &name);
    UserMapper* setPassword(const QString &password);
    QSqlDatabase getDb() const;


private:
    QSqlDatabase db;
};

#endif // USER_MAPPER_H
